#ifndef __CCOLOR_H__
#define __CCOLOR_H__

#include "CTypes.h"

typedef enum COLOR_TYPES
{
	CT_RGBA		= 0,
	CT_ABGR		= 1,
	CT_ARGB		= 2,
	CT_RGB		= 3,
	CT_BGR		= 4,
	CT_MAX		= 0xFF
} COLOR_TYPES;

class CColor
{
public:
	f32 r;
	f32 g;
	f32 b;
	f32 a;

public:
	CColor() : r(0.0), g(0.0), b(0.0), a(1.0)									{}
	CColor(vPos r,vPos g,vPos b,vPos a = 1.0) : r(r), g(g), b(b), a(a)			{}
	CColor(vPos *v) : r(v[0]), g(v[1]), b(v[2]), a(v[3])						{}
	virtual ~CColor()															{}
	inline void SetRGB(vPos nr,vPos ng,vPos nb)									{r = nr; g =ng; b = nb; }
	inline void SetRGBA(vPos nr,vPos ng,vPos nb,vPos na)						{a = na; r = nr; g =ng; b = nb; }

	u32 GetColorUInt(COLOR_TYPES ct=CT_RGBA)
	{
		u8 RetR = (u8)(r * 255.0);
		u8 RetG = (u8)(g * 255.0);
		u8 RetB = (u8)(b * 255.0);
		u8 RetA;
		u32 Ret;

		if (ct == CT_RGBA || ct == CT_ABGR || ct == CT_ARGB)
			RetA = (u8)(a * 255.0);

		switch (ct)
		{
			default:
			case CT_RGBA:
			{
				Ret = (RetR<<24) | (RetG<<16) | (RetB<<8) | RetA;
			}
			break;

			case CT_ABGR:
			{
				Ret = (RetA<<24) | (RetB<<16) | (RetG<<8) | RetR;
			}
			break;

			case CT_ARGB:
			{
				Ret = (RetA<<24) | (RetR<<16) | (RetG<<8) | RetB;
			}
			break;

			case CT_RGB:
			{
				Ret = 0x00000000 | (RetR<<16) | (RetG<<8) | RetB;
			}
			break;

			case CT_BGR:
			{
				Ret = 0x00000000 | (RetB<<16) | (RetG<<8) | RetR;
			}
			break;

		}

		return Ret;
	}

	inline f32 *GetColorVector()
	{
		return &r;
	}

	inline void MultScalar(vPos Scalar)
	{
		r *= Scalar;
		g *= Scalar;
		b *= Scalar;
	}
};

#endif

